package com.lottery.game.controller.v2.game.room;

import com.lottery.game.annotation.Current;
import com.lottery.game.common.Response;
import com.lottery.game.common.model.PageInfo;
import com.lottery.game.core.model.dto.UserToken;
import com.lottery.game.core.model.dto.game.GameRoomTO;
import com.lottery.game.core.model.dto.game.query.RoomQuery;
import com.lottery.game.core.modules.entity.user.ChatRecord;
import com.lottery.game.core.modules.service.app.ChatRecordService;
import com.lottery.game.core.modules.service.game.GameRoomV2Service;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import springfox.documentation.annotations.ApiIgnore;

/**
 * @author : yinlin
 * @version : 1.0
 * @date : 2019-02-19 23:22
 * @Description :
 * @Copyright : Copyright (c) 2018
 * @Company : KeRuYun Technology(Beijing) Chengdu Co. Ltd.
 * @link : com.runshang.apps.cloudgame.controller.v2.game.room.GameRoomController
 */
@RestController
@RequestMapping("/api/v2/game")
@Api(tags = "APP-游戏房间接口")
@Slf4j
public class GameRoomController {

    @Autowired
    private GameRoomV2Service gameRoomV2Service;
    @Autowired
    private ChatRecordService chatRecordService;

    @RequestMapping(value = "room/query", method = RequestMethod.POST, produces = {MediaType.APPLICATION_JSON_UTF8_VALUE})
    @ApiOperation(value = "根据彩种类型查询房间列表", notes = "根据彩种类型查询房间列表")
    public PageInfo<GameRoomTO> query(@RequestBody RoomQuery query) {
        return gameRoomV2Service.query(query);
    }
    
    @RequestMapping(value = "room/queryChatRecordByRoomnumber", method = RequestMethod.GET, produces = {MediaType.APPLICATION_JSON_UTF8_VALUE})
    @ApiOperation(value = "房间聊天记录获取", notes = "房间聊天记录获取")
    @ApiImplicitParams({
    	@ApiImplicitParam(name="roomNumber",value="房间号"),
    	@ApiImplicitParam(name="page",value="当前页"),
    	@ApiImplicitParam(name="row",value="每页大小"),
    	@ApiImplicitParam(name = "ticket", value = "令牌ticket", dataType = "String", paramType = "header",required = true)
    })
    public List<ChatRecord> queryChatRecordByRoomnumber(@ApiIgnore @Current UserToken ticket,String roomNumber,int page,int row) {
    	List<ChatRecord> list=null;
		try {
			list = chatRecordService.queryChatRecordByRoomnumber(roomNumber, page, row);
		} catch (Exception e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
        return list;
    }
}
